package com.java.blog.task;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import com.java.blog.service.CrawlService;

import lombok.extern.log4j.Log4j;

@Component("taskJob")
@Log4j
public class TaskJob {

	@Autowired
	private CrawlService crawlService;

	/**
	 * @Describe:每隔30分钟爬一次糗事百科热门，存入redis
	 */
	@Scheduled(cron = "0 0/30 * * * ?")
	public void startQiushi() {
		log.info("定时任务开启：爬取糗事百科");
		crawlService.startQiushi();
		log.info("定时任务结束：爬取糗事百科");
	}

	@Scheduled(cron = "*/5 * * * * ?") // 每隔5秒执行一次
	public void test() {
		// System.out.println("定时任务开启，当前执行" + (times++) + "次");
	}

}
